package com.qdxwx.sms;

import com.qdxwx.sms.tencent.v20210111.models.SendSmsRequest;

import java.util.ArrayList;
import java.util.List;

/**
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
public class QdxSmsRequest extends SendSmsRequest {
    /**
     * 短信应用Id
     */
    private final String sdkAppId = "1400351011";
    /**
     * 短信签名
     */
    private final String sdkSign = "启点学";

    public QdxSmsRequest(){
        super.setSmsSdkAppId(this.sdkAppId);
        super.setSignName(this.sdkSign);
    }

    public QdxSmsRequest(String sdkAppId, String sdkSign){
        super.setSmsSdkAppId(sdkAppId);
        super.setSignName(sdkSign);
    }

    /**
     * 设置单个手机号码
     *
     * @param phoneNumber 手机号
     */
    public void setPhoneNumber(String phoneNumber) {
        if (phoneNumber == null) return;
        if (phoneNumber.charAt(0) != '+') {
            phoneNumber = "+86" + phoneNumber;
        }
        super.setPhoneNumberSet(new String[]{phoneNumber});
    }

    @Override
    public void setPhoneNumberSet(String[] PhoneNumberSet) {
        if (PhoneNumberSet == null) return;
        List<String> phoneList = new ArrayList<>();
        for (String phoneNumber : PhoneNumberSet) {
            if (phoneNumber.charAt(0) != '+') {
                phoneNumber = "+86" + phoneNumber;
            }
            phoneList.add(phoneNumber);
        }
        super.setPhoneNumberSet(phoneList.toArray(new String[0]));
    }

    //设置单个参数
    public void setTemplateParam(String templateParam) {
        super.setTemplateParamSet(new String[]{templateParam});
    }

    @Override
    public String toString() {
        return "QdxSmsRequest{" +
                "sdkAppId='" + sdkAppId + '\'' +
                ", sdkSign='" + sdkSign + '\'' +
                "} " + super.toString();
    }
}